<!DOCTYPE html>
<html lang="zh">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="{{ url_for('admin.static', filename='images/favicon.ico')}}">

        <title>{% block title %}藕丝空间 {% endblock %}</title>
        {% block css %}
            <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
            <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

            <!-- 个性化主题文件 -->

            <link href="{{ url_for('admin.static', filename='css/admin.css')}}" rel="stylesheet">
        {% endblock %}

        {% block js %}
            <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
            <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
            <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
            <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

            <!-- 个性化 js 文件 -->
            <script src="{{ url_for('admin.static', filename='js/admin.js')}}"></script>
            {{ moment.include_moment(local_js=url_for('admin.static', filename='js/moment-with-locales.js')) }}
            {{ moment.lang('zh-cn') }}
        {% endblock %}
    </head>

    <body>
        <div class="container-fluid">
            <div class="row">
                <nav class="navbar navbar-default">
                    <div class="container-fluid">
                        <!-- Brand and toggle get grouped for better mobile display -->
                        <div class="navbar-header">
                            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                                <span class="sr-only">Toggle navigation</span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
                            <a class="navbar-brand strong" href="{{ url_for('admin.finder', path='basedir') }}">图库 </a>
                        </div>
                        <!-- Collect the nav links, forms, and other content for toggling -->
                        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                            <ul class="nav navbar-nav">
                                <li><a>{{ directory.current_path }} <span class="sr-only">(current)</span></a></li>
                                {% if not directory.current_path %}
                                <li class="disabled"><a type="button" title="返回" class="btn"><i class="glyphicon glyphicon-chevron-left"></i> </a></li>
                                {% else %}
                                <li><a href="javascript:history.back(-1)" type="button" title="返回" class="btn"><i class="glyphicon glyphicon-chevron-left"></i> </a></li>
                                {% endif %}
                                <li><form id="images_upload" method="post" role="form" enctype="multipart/form-data">
                                    <label class="btn btn-lg" title="上传图片">
                                        <i class="glyphicon glyphicon-cloud-upload"></i>  <input type="file" multiple="multiple" name="file[]" style="display: none;">
                                    </label>
                                    </form>
                                </li>
                                {% if directory.current_path == '' %}
                                <li>
                                    <a type="button" title="新建文件夹" class="btn" data-toggle="modal" data-target="#myFolder"><i class="glyphicon glyphicon-plus"></i> </a>
                                </li>
                                {% endif %}
                            </ul>
                            <ul class="nav navbar-nav navbar-right">
                                <li><a href="{{ url_for('main.index') }}">主页</a></li>
                                <li><a href="{{ url_for('admin.index') }}">管理页</a></li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> {{ current_user.username }} <span class="caret"></span></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="{{ url_for('admin.logout') }}">退出</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div><!-- /.navbar-collapse -->
                    </div><!-- /.container-fluid -->
                </nav>
                {% for d in directory.query %}
                {% if d.type == 'folder' %}
                <div class="col-xs-4 col-sm-1">
                    <a href="{{ url_for('admin.finder', path=d.name) }}" id="folder_{{ loop.index }}">
                        <img class="picture" src="{{ url_for('admin.static', filename='images/folder.jpg') }}" alt="{{ d.name }}">
                    </a>
                    <p class="small">{{ d.name|striptags|truncate(length=16, killwords=False, end="...") }}</p>
                </div>
                {% else %}
                <div class="col-xs-4 col-sm-1">
                    <img class="picture" src="{{ url_for('admin.static', filename='pictures/'+directory.current_path+'/'+d.name) }}" alt="{{ d.name }}">
                    <p class="small">{{ d.name|striptags|truncate(length=16, killwords=False, end="...") }}</p>
                </div>
                {% endif %}
                {% endfor %}
            </div>
            <div class="modal fade" id="myFolder" tabindex="-1" role="dialog" aria-labelledby="myFolderLabel">
                <div class="modal-dialog modal-sm" role="document">
                    <form method="post" role="form" action="">
                        {{ addFolderForm.hidden_tag() }}
                        <div class="modal-content">
                            <div class="modal-body">
                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-folder-open"></i> </span>
                                        {{ addFolderForm.directory(class="form-control", placeholder="新建文件夹") }}
                                    </div>
                                </div>
                                <div class="text-right">
                                    {{ addFolderForm.submit(class="btn btn-xs btn-primary") }}
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </body>
</html>


